import {
  BasicColumn
} from '/@/components/Table';
import {
  FormSchema
} from '/@/components/Table';
import {
  JVxeTypes,
  JVxeColumn
} from '/@/components/jeecg/JVxeTable/types'
import {
  render
} from '/@/utils/common/renderUtils';

//列表数据
export const columns: BasicColumn[] = [
  {
    title: '产品编号',
    align: "center",
    dataIndex: 'materialNumberCoding',
  },
  {
    title: '产品名称',
    align: "center",
    dataIndex: 'materialNumberName',
    width: 180
  },{
    title: '图号',
    dataIndex: 'drawingNo',
    key: 'drawingNo',
    width: 150,
  }, {
    title: '资源组编码',
    dataIndex: 'resourceGroupCode',
    key: 'resourceGroupCode',
    width: 120
  },{
    title: '资源组',
    dataIndex: 'resourceGroup',
    key: 'resourceGroup',
  },{
    title: '资源名称',
    dataIndex: 'resourceGroupItemName',
    key: 'resourceGroupItemName',
  },
  {
    title: '资源优先顺序',
    dataIndex: 'resourcePriority',
    key: 'resourcePriority',
  },  
  {
    title: '工艺顺序',
    dataIndex: 'processOrder',
    key: 'processOrder',
  },  
  {
    title: '工作中心',
    align: "center",
    dataIndex: 'workCenter'
  }, {
    title: '产品工艺',
    align: "center",
    dataIndex: 'processName'
  }, {
    title: '前置时间',
    dataIndex: 'leadTime',
    key: 'leadTime',
    width: 100
  }, {
    title: '单位产能',
    dataIndex: 'unitCapacity',
    key: 'unitCapacity',
    width: 100
  },
 {
    title: '工序提前期',
    dataIndex: 'shiftHours',
    key: 'shiftHours',
    width: 100
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'remark'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [{
  label: "产品编号",
  field: 'materialNumberCoding',
  component: 'Input',
  colProps: {
    span: 6
  },
},
{
  label: "名称",
  field: 'materialNumberName',
  component: 'Input',
  colProps: {
    span: 6
  },
},
];
//表单数据
export const formSchema: FormSchema[] = [{
  label: '组织名称',
  field: 'organizationName',
  component: 'JSelectDept',
  componentProps: ({ }) => {
    return {
      multiple: false,
      showButton: false,
      checkable: false
    }
  },
},
{
  label: '料品分类',
  field: 'materialClassification',
  component: 'Input',
},
{
  label: '工作中心',
  field: 'workCenter',
  component: 'Input',
},
{
  label: '料号编码',
  field: 'materialNumberCoding',
  component: 'Input',
},
{
  label: '料号名称',
  field: 'materialNumberName',
  component: 'Input',
},
{
  label: '生效日期',
  field: 'effectiveDate',
  component: 'DatePicker',
},
{
  label: '失效日期',
  field: 'expiryDate',
  component: 'DatePicker',
},
{
  label: '展阶过滤采购件',
  field: 'stepFilterPurchase',
  component: 'Select',
  defaultValue: 0,
  componentProps: {
    options: [{
      value: 1,
      label: '是'
    }, {
      value: 0,
      label: '否'
    }],
    stringToNumber: true,
  }
},
{
  label: '第三方编码',
  field: 'thirdPartyCode',
  component: 'Input',
  ifShow: false
},
{
  label: '备注',
  field: 'remark',
  component: 'Input',
},
// TODO 主键隐藏字段，目前写死为ID
{
  label: '',
  field: 'id',
  component: 'Input',
  show: false
},
];
// 产品组件  表格数据
export const productColumns = [{
  title: '料号',
  dataIndex: 'materialNumberCoding',
  key: 'materialNumberCoding',
  //resizable: true,
  width: 150,
}, {
  title: '品名',
  dataIndex: 'materialNumberName',
  key: 'materialNumberName',
  //resizable: true,
  width: 150,
}, 
{
  title: '规格',
  dataIndex: 'spec',
  key: 'spec',
  // resizable: true,
  width: 150,
}, {
  title: '形态属性',
  dataIndex: 'materialTypeAttribute',
  key: 'materialTypeAttribute',
  resizable: true,
  width: 150,
  customRender: ({ text }) => {
    return render.renderDict(text, 'marbas_material_type_attribute')
  },
}, 
{
  title: '图号',
  dataIndex: 'drawingNo',
  key: 'drawingNo',
  // resizable: true,
  width: 150,
},];

// 产品工艺 表格数据
export const productProcessColumns = [{
  title: '料号',
  dataIndex: 'materialNumberCoding',
  key: 'materialNumberCoding',
  //resizable: true,
  width: 150,
}, {
  title: '品名',
  dataIndex: 'materialNumberName',
  key: 'materialNumberName',
  //resizable: true,
  width: 150,
}, 
// {
//   title: '规格',
//   dataIndex: 'spec',
//   key: 'spec',
//   // resizable: true,
//   width: 150,
// }, {
//   title: '形态属性',
//   dataIndex: 'materialTypeAttribute',
//   key: 'materialTypeAttribute',
//   resizable: true,
//   customRender: ({ text }) => {
//     return render.renderDict(text, 'marbas_material_type_attribute')
//   },
//   width: 150,
// }, 
{
  title: '图号',
  dataIndex: 'drawingNo',
  key: 'drawingNo',
  // resizable: true,
  width: 150,
}, {
  title: '工作中心',
  dataIndex: 'workCenter',
  key: 'workCenter',
  // resizable: true,
  width: 150,
},{
  title: '工序名称',
  dataIndex: 'processName',
  key: 'processName',
  // resizable: true,
  width: 150,
},{
  title: '工艺编码',
  dataIndex: 'operationNumber',
  key: 'operationNumber',
  // resizable: true,
  width: 150,
},{
  title: '工艺顺序',
  dataIndex: 'processOrder',
  key: 'processOrder',
  // resizable: true,
  width: 150,
},  {
  title: '是否委外',
  dataIndex: 'outsourcingNot',
  key: 'outsourcingNot',
  stringToNumber: true,
  customRender: ({ text }) => {
    return text == 1 ? '是' : '否'
  },
  // resizable: true,
  width: 150,
},{
  title: '是否总装工艺',
  dataIndex: 'finalAssembly',
  key: 'finalAssembly',
  stringToNumber: true,
  customRender: ({ text }) => {
    return text == 1 ? '是' : '否'
  },
  // resizable: true,
  width: 150,
},
{
  title: '资源编号',
  dataIndex: 'resourceGroupItemCode',
  key: 'resourceGroupItemCode',
  // resizable: true,
  width: 150,
},
{
  title: '资源名称',
  dataIndex: 'resourceGroupItemName',
  key: 'resourceGroupItemName',
  // resizable: true,
  width: 150,
},
{
  title: '资源优先顺序',
  dataIndex: 'resourcePriority',
  key: 'resourcePriority',
  // resizable: true,
  width: 150,
},
// {
//   title: '资源组',
//   dataIndex: 'resourceGroup',
//   key: 'resourceGroup',
//   // resizable: true,
//   width: 150,
// },  
{
  title: '单位产能',
  dataIndex: 'unitCapacity',
  key: 'unitCapacity',
  // resizable: true,
  width: 150,
}, 
{
  title: '前置时间',
  dataIndex: 'leadTime',
  key: 'leadTime',
  // resizable: true,
  width: 150,
}, 
{
  title: '产能峰值',
  dataIndex: 'peakCapacity',
  key: 'peakCapacity',
  // resizable: true,
  width: 150,
},
{
  title: '工序提前期',
  dataIndex: 'shiftHours',
  key: 'shiftHours',
  // resizable: true,
  width: 150,
},
// {
//   title: '用时单位',
//   dataIndex: 'timeUnit',
//   key: 'timeUnit',
//   // resizable: true,
//   width: 150,
// },
    {
    title: '操作',
    dataIndex: 'operation',
    key: 'operation',
    fixed:"right",
    width: 150,
  },
];

//子表单数据
//子表表格配置
export const psProductProcessTechnicColumns: JVxeColumn[] = [
  {
    title: '组织名称',
    key: 'organizationName',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '组件名称',
    key: 'componentName',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '图号',
    key: 'figureNumber',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '工艺编码',
    key: 'operationNumber',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '工序名称',
    key: 'processName',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '工种',
    key: 'craft',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '是否委外',
    key: 'outsourcingNot',
    type: JVxeTypes.select,
    width: "200px",
    placeholder: '请输入${title}',
    options: [{
      value: 0,
      label: '否'
    }, {
      value: 1,
      label: '是'
    }],
  },
  {
    title: '用工',
    key: 'employment',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '用时',
    key: 'timeSpent',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '前置时间',
    key: 'leadTime',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '工序提前期',
    key: 'shiftHours',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '理想产能',
    key: 'idealProductivity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '单位时间正常产能',
    key: 'eachUnitNormalCapacity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '资源组Id',
    key: 'resourceGroupId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '资源组名称',
    key: 'resourceGroup',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '资源产量拆分值',
    key: 'resourceOutput',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '单台产品单位设备用时',
    key: 'equipmentTime',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '单台产品单位设备人时',
    key: 'equipmentPerson',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '第三方编码',
    key: 'thirdPartyCode',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '备注',
    key: 'remark',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
]

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
